#define _CRT SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
    int kcount(int num)
    {
        int count = 0;
        while (num > 0)
        {
            num &= (num - 1);
            count++;
        }
        return count;
    }
    int sumIndicesWithKSetBits(vector<int>& nums, int k) {
        int sum = 0;
        for (auto i : nums)
        {
            int ret = kcount(i);
            if (ret == k)
            {
                sum += i;
            }
        }
        return sum;
    }
};
int main()
{
    Solution s;
    vector<int> arr(20, 0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    int ret=s.sumIndicesWithKSetBits(arr,2);
    cout << ret;
    return 0;
}

